<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Iphone extends CI_Controller {
	
	protected $_data = array();
	
	function __construct()
	{
		parent::__construct();
		$this->load->model(array('location_model'));
	}
	
	
	public function index()
	{
		$this->load->view('welcome_message');
	}
	
	public function statistic()
	{
		$idLocation	=	$this->input->get('idLocation');
		$count		=	$this->input->get('count');
		if(!$count)$count = 10;
		if(!$idLocation)$idLocation = 'mb';
		
		$idLocation	=	strtoupper($idLocation);
		//echo $idLocation.$count;
		
		$this->load->model('mobile_statistics_model');
		$location	=	$this->location_model->get_by(array('code' => $idLocation));
		$result	=	array();
		if($location)
		{
			$data	=	$this->mobile_statistics_model->order_by('update_date','DESC')->get_by(array('lid' => $location->id, 'num_statistics' => $count));
			if($data)
			{
				$result =	json_decode($data->result);
			}
		}
		
		$this->_data['result']	=	$result;
		$this->_data['days']	=	$count;
		$this->_data['tmpl']	=	'client/iphone/statistic';
		$this->load->view('client/iphone/content',$this->_data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */